<template>
	<view>
		<scroll-view scroll-y class="page" @scrolltolower="loadmore()">
			<image src="/static/indexBg.png" mode="widthFix" class="response" style="position: fixed;z-index: 99;"></image>
			<view style="height: 325rpx;"></view>
			<block v-for="(item,index) in list" :key="index">
				<view @click="detail(item)">
					<hm-nformation-card :item="item" :index='index'></hm-nformation-card>
				</view>
			</block>
			<loadMore :loadtext="loadtext" v-if="show"></loadMore>
		</scroll-view>
	</view>
</template>

<script>
	import HmNformationCard from "@/components/hm-information-card/index.vue";
	import loadMore from "../../components/common/load-more.vue";
	export default {
		components: {
			HmNformationCard,
			loadMore
		},
		data() {
			return {
				isRotate: false,
				page: 1,
				perpage: 10,
				show: false,
				loadtext: "上拉加载更多",
				list: [],
			};
		},
		mounted() {
			this.getList();
		},

		methods: {

			detail(item) {
				uni.redirectTo({
					url: "/pages/home/one/one?id=" + item.id + "&uuid=" + item.user_uuid + "&date=" + item.moment_createtime
				})
			},
			loadmore() {
				if (this.loadtext != "上拉加载更多") {
					return;
				}
				this.loadtext = "加载中...";
				this.page++;
				this.getList();
			},

			async getList() {
				let options = {
					data: {
						s: "SVIP.Szskj_MyApi.AListOkayapimoment",
						page: this.page,
					},
					method: "POST",
				};
				let res = await this.$myRuquest(options);
				if (res.data.data.err_code == 0) {
					let arr = res.data.data.list;
					this.list = this.page > 1 ? this.list.concat(arr) : arr;
					if (arr.length < 10) {
						this.loadtext = "没有更多数据了";
						if (this.page == 1) {
							this.loadtext = "";
						}
					} else {
						this.loadtext = "上拉加载更多";
					}
					this.show = true;


					return;
				} else {
					uni.showToast({
						icon: "",
						title: res.data.data.err_msg,
					});
				}
			},
	
		},
	};
</script>

<style>
	.page {
		height: 100vh;
	}
</style>
